import type { IResponseBody } from "@/common/Responsetypes";
import http from "./request";
import type { IPoiExt } from "@/common/MapTypes";

export function add(data: object): Promise<IResponseBody<object>> {
  return http.post("/markers", data);
}

export function modify(): Promise<IResponseBody<object>> {
  return http.put("/markers");
}

export function del(id: string): Promise<IResponseBody<object>> {
  return http.delete(`/markers/${id}`);
}

export function findById(): Promise<IResponseBody<IPoiExt[]>> {
  return http.get("/markers");
}

/**
 * 获取用户公开的 Marker 列表
 * @param uid
 * @returns
 */
export function getOpenMarker(uid: number): Promise<IResponseBody<IPoiExt[]>> {
  return http.get("/markers/findById", {
    params: {
      uid,
    },
  });
}

export function getMarkerAttrNmae(
  m_id: number
): Promise<IResponseBody<object>> {
  return http.get("/markers/attrname", {
    params: {
      m_id,
    },
  });
}
